import java.util.Arrays;
class Dog{
    public int age;
    public String name;
    public void test(){
        System.out.println("叫！");
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setName(String name) {
        this.name = name;
    }
}
public class TestDemo {
    int a=10;
    public static String myToString(int[]arr){
        String x="[";
        for (int i = 0; i < arr.length; i++) {
            x+=arr[i];
            if(i!= arr.length-1){
                x+=",";
            }
        }
        x+="]";
        return x;
    }

    /**
     *
     * 二分查找
     */
    public static int search(int[]arr,int index){
        int left=0;
        int right=arr.length;
        int mid;
        while(left<right){
            mid=(left+right)/2;
            if(index<arr[mid]){
                right=mid-1;
            }else if(index>arr[mid]){
                left=mid+1;
            }else {
                return mid;
            }
        }
            return -1;
    }

    /**
     *
     * 冒泡排序
     */
    public static void maopao(int[]arr){
        for (int i = 0; i < arr.length-1; i++) {
            boolean flg=false;
            for (int j = 0; j <arr.length-i-1 ; j++) {
                if(arr[j]>arr[j+1]){
                    int tmp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=tmp;
                    flg=true;
                }
            }
            if(flg==false){
                return;
            }
        }
    }

    /**
     *
     * 数组逆序
     */
    public static void mySort(int[]arr){
        int left=0;
        int right=arr.length-1;
        while (left<right){
            int tmp=arr[left];
            arr[left]=arr[right];
            arr[right]=tmp;
            left++;
            right--;
        }
    }

    public static void main(String[] args) {
        Dog dog=new Dog();
        dog.setAge(12);
    }

    public static void main2(String[] args) {
        int[][]arr=new int[][]{{1,2,3},{4,5,6}};
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j]);
            }
            System.out.println();
        }

        for (int[]tmp:arr) {
            for (int x:tmp) {
                System.out.print(x);
            }
            System.out.println();
        }

        System.out.println(Arrays.deepToString(arr));

        int[][]arr2=new int[2][];
        arr2[0]=new int[2];
        arr2[1]=new int[6];
        System.out.println(Arrays.deepToString(arr2));
    }
    public static void main1(String[] args) {
       /*int[]arr=new int[]{1,2,3,4};
       int[]arr2=new int[4];
        for (int i = 0; i < arr.length; i++) {
            arr2[i]=arr[i];
        }
        System.out.println(Arrays.toString(arr));
        arr2[0]=88;
        System.out.println(Arrays.toString(arr2));*/

        TestDemo testDemo=new TestDemo();
        TestDemo testDemo1=new TestDemo();
        TestDemo[]arr3=new TestDemo[]{testDemo1,testDemo1};
        TestDemo[]arr4=arr3.clone();
        arr4[0].a=99;
        System.out.println(arr3[0].a);
        System.out.println(arr4[0].a);
        int[]arr=new int[]{4,6,1,8,3};
        mySort(arr);
        System.out.println(Arrays.toString(arr));

        int[][]arry=new int[][]{{1,2,3},{4,5,6}};
        System.out.println(arry.length);
        System.out.println(arry[0].length);

        System.out.println(arry);
        System.out.println(arry[1]);
        System.out.println(arry[0]);
        int[][]arry1=new int[2][3];
    }
}
